
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;


public class listLocalImgRef {
    private List<LocalImgRef> list;
    public listLocalImgRef(){
        list = new ArrayList<LocalImgRef>();
    }

    @Override
    public String toString() {
        String all = new String();
       for(int i = 0; i<list.size(); i++){
            all = all +"\n"+ list.get(i).ScreenName+" "+list.get(i).url+"\n";
        }
        return all;
    }
    public void addImg(LocalImgRef e){
        list.add(e);
    }
    public void removeImg(LocalImgRef e){
        list.remove(e);
    }
    public void replace(LocalImgRef a, LocalImgRef b){
        int index = list.indexOf(a);
        list.remove(index);
        list.add(index, b);
        System.out.println("replaced "+a.url+" for "+b.url);
        System.out.println(list);
    }
    public boolean exist(LocalImgRef e){
        if(list.contains(e)) return true;
        else return false;
    }
    public LocalImgRef getBySearch(LocalImgRef e){
        return list.get(list.indexOf(e));
    }
    private boolean checkURL(String URL){
     try
     {
         java.net.URL url = new java.net.URL(URL);
         InputStream is = url.openStream();
         return true;
         }
         catch (Exception e)
         {
         return false;
     }
    }
}
